import java.util.Stack;

import static java.lang.Character.isDigit;

class Solution {
    class Solution {
        public int evalRPN(String[] tokens) {
            int ans = 0;
            if(tokens == null || tokens.length == 0) return ans;
            Stack<Integer> stack = new Stack<>();
            for(String str : tokens){
                if(str.equals("+") || str.equals("-") || str.equals("*") || str.equals("/")){
                    int a = stack.pop(), b = stack.pop();
                    if(str.equals("+")) b += a;
                    if(str.equals("-")) b -= a;
                    if(str.equals("*")) b *= a;
                    if(str.equals("/")) b /= a;
                    stack.push(b);
                }else{
                    stack.push(Integer.parseInt(str));
                }
            }
            return stack.pop();
        }
    }


    public static void main(String[] args) {
        String[] s={"2","1","+","3","*"};
        evalRPN(s);
    }
}
public class lc150 {
}
